from django.urls import path
from rest_framework.routers import DefaultRouter
from . import views

router = DefaultRouter(trailing_slash=False)
# 注册项目视图的路由
router.register('project', views.ProjectViewSets, basename='project')
# 注册host视图的路由
router.register('host', views.HostViewSets, basename="host")
# 注册接口视图的路由
router.register('api', views.ApiViewSets, basename="api")

app_name = "apitest"
urlpatterns = [
                  # 注册运行api视图的路由
                  path('run/api/<int:api_id>', views.RunApiView.as_view(), name="run_api"),
                  # 注册新增case视图的路由
                  path('case', views.CaseView.as_view(), name='case'),
                  # 修改case视图的路由
                  path('case/<int:case_id>', views.CaseView.as_view(), name="edit_case"),
                  # 运行用例视图的路由
                  path('run/case/<int:case_id>', views.RunCaseView.as_view(), name="run_case"),
                  # 用例执行记录路由
                  path('record', views.RecordView.as_view(), name="record"),
                  # 获取人物列表路由
                  path('task', views.CrontabTaskView.as_view(), name="task"),
                  # 修改任务路由
                  path('task/<int:task_id>', views.CrontabTaskView.as_view(), name="update_task"),
                  # 任务状态路由
                  path('task/<int:task_id>/<int:target_status>', views.StartStopTaskView.as_view(), name="task_status"),
                  # 首页视图路由
                  path("index", views.IndexView.as_view(), name="index"),
              ] + router.urls
